package com.model.defaults.actionbar;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionBarItem;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.UserContextName;

public class ModelDefaultActionbarItemsTask {

    public static void createActionBarItemsProjectSubTask ( Session session,
                                                            Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;

        KeyValue actionScriptParam = new KeyValue("p1", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptText("%s?{p1}", GlobalConstants.SERVLET_SUBTASKADD);
        actionScript.setActionScriptType("servlet");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_SUBTASKSLIST);
        pojo = new ActionBarItem();
        pojo.setName("BrowseReports");
        pojo.setCaption("Add subtask");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);
    }



    public static void createActionBarItemsTaskOpen ( Session session,
                                                      Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;

        KeyValue actionScriptParam = new KeyValue("p1", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptType("servlet");
        actionScript.setActionScriptText("%s?{p1}", GlobalConstants.SERVLET_TASKUPDATE);
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
        pojo = new ActionBarItem();
        pojo.setName("EditDescription");
        pojo.setCaption("Edit task attributes");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }



    public static void createActionBarItemsTaskSubtaskAdd ( Session session,
                                                            Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;
        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_SUBTASKADD);

        KeyValue actionScriptParam = new KeyValue("form", "?");
        session.save(actionScriptParam);

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptType("javascript");
        actionScript.setActionScriptText("javascript:document.{form}.submit();");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        pojo = new ActionBarItem();
        pojo.setName("save_subtask");
        pojo.setCaption("Save new subtask");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }



    public static void createActionBarItemsTaskAdd ( Session session,
                                                     Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;
        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKADD);

        KeyValue actionScriptParam = new KeyValue("form", "?");
        session.save(actionScriptParam);

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptType("javascript");
        actionScript.setActionScriptText("javascript:document.{form}.submit();");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        pojo = new ActionBarItem();
        pojo.setName("save_task");
        pojo.setCaption("Save new task");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }



    public static void createActionBarItemsTaskUpdate ( Session session,
                                                        Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;
        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAUPDATE);

        KeyValue actionScriptParam = new KeyValue("form", "?");
        session.save(actionScriptParam);

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptType("javascript");
        actionScript.setActionScriptText("javascript:document.{form}.submit();");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        pojo = new ActionBarItem();
        pojo.setName("update_task");
        pojo.setCaption("Update task attributes");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }

}
